package com.project_task.controller;

import com.project_task.dto.ProjectPageQueryDTO;
import com.project_task.dto.TaskDTO;
import com.project_task.dto.TaskPageQueryDTO;
import com.project_task.result.PageResult;
import com.project_task.result.Result;
import com.project_task.service.TaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/task")
@Api(tags = "任务管理相关接口")
@Slf4j
public class TaskController {

    @Autowired
    private TaskService taskService;

    @PostMapping("/save")
    @ApiOperation("创建任务")
    public Result save(@RequestBody TaskDTO taskDTO){
        log.info("新增任务：{}", taskDTO);
        taskService.save(taskDTO);
        return Result.success();
    }

    @GetMapping("/page")
    @ApiOperation("任务分页查询")
    public Result<PageResult> page(TaskPageQueryDTO taskPageQueryDTO){
        log.info("任务分页查询:{}", taskPageQueryDTO);
        PageResult pageResult = taskService.pageQuery(taskPageQueryDTO);
        return Result.success(pageResult);
    }

}
